import http from "@/api/http";
import { useJwt } from '@vueuse/integrations/useJwt'
import { ref } from 'vue'
export async function login(userName, pass) {
  try {
    const result = await http
      .post("/user/login", { username: userName, password: pass })
      .then(function (response) {
        // useJwt.set(response.data.access);
        const { header, payload } = useJwt(ref(response.data.access))
        console.log(payload.value,'----------jwt--------');
        return response;
      });
    return result;
  } catch (error) {
    console.log(error);
    if (error.response.status === 401) {
      return error.response;
    }
    // console.log(error);
  }
}
